package com.ruoyi.web.controller.biz;

import java.util.List;

import com.ruoyi.biz.domain.CaseInfo;
import com.ruoyi.biz.service.ICaseInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 信息安全测试报告Controller
 * 
 * @author jiangnan
 * @date 2021-03-09
 */
@Controller
@RequestMapping("/biz/caseinfo")
public class CaseInfoController extends BaseController
{
    private String prefix = "biz/caseinfo";

    @Autowired
    private ICaseInfoService caseInfoService;

    @RequiresPermissions("bis:caseinfo:view")
    @GetMapping()
    public String caseinfo()
    {
        return prefix + "/caseinfo";
    }

    /**
     * 查询信息安全测试报告列表
     */
    @RequiresPermissions("bis:caseinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CaseInfo caseInfo)
    {
        startPage();
        List<CaseInfo> list = caseInfoService.selectCaseInfoList(caseInfo);
        return getDataTable(list);
    }

    /**
     * 导出信息安全测试报告列表
     */
    @RequiresPermissions("bis:caseinfo:export")
    @Log(title = "信息安全测试报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CaseInfo caseInfo)
    {
        List<CaseInfo> list = caseInfoService.selectCaseInfoList(caseInfo);
        ExcelUtil<CaseInfo> util = new ExcelUtil<CaseInfo>(CaseInfo.class);
        return util.exportExcel(list, "caseinfo");
    }

    /**
     * 新增信息安全测试报告
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存信息安全测试报告
     */
    @RequiresPermissions("bis:caseinfo:add")
    @Log(title = "信息安全测试报告", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CaseInfo caseInfo)
    {
        return toAjax(caseInfoService.insertCaseInfo(caseInfo));
    }

    /**
     * 修改信息安全测试报告
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CaseInfo caseInfo = caseInfoService.selectCaseInfoById(id);
        mmap.put("caseInfo", caseInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存信息安全测试报告
     */
    @RequiresPermissions("bis:caseinfo:edit")
    @Log(title = "信息安全测试报告", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CaseInfo caseInfo)
    {
        return toAjax(caseInfoService.updateCaseInfo(caseInfo));
    }

    /**
     * 删除信息安全测试报告
     */
    @RequiresPermissions("bis:caseinfo:remove")
    @Log(title = "信息安全测试报告", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(caseInfoService.deleteCaseInfoByIds(ids));
    }
}
